package com.atwulidun.composite08;

import java.util.ArrayList;
import java.util.List;

public class University extends OrganizationComponent {
    // 聚合学院
    private List<OrganizationComponent> colleges = new ArrayList<>();

    public University(String name, String des) {
        super(name, des);
    }

    // 增加学院的方法
    @Override
    protected void add(OrganizationComponent organizationComponent) {
        colleges.add(organizationComponent);
    }
    // 删除学院方法
    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        colleges.remove(organizationComponent);
    }
    // 打印当前大学以及所包含学院方法
    @Override
    protected void print() {
        System.out.println("-----------------" + getName() + "------------------");
        for (OrganizationComponent college : colleges) {
            college.print();
        }
    }
}
